package com.yudean.esb.dao.esb;

import com.yudean.esb.domain.esb.EsbServiceConfigRelation;
import com.yudean.esb.mapper.esb.EsbServiceConfigRelationMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
@Repository
public class EsbServiceConfigRelationDao {
    @Resource
    private EsbServiceConfigRelationMapper esbServiceConfigRelationMapper;

    public List<EsbServiceConfigRelation> getAll() {
        List<EsbServiceConfigRelation> list = esbServiceConfigRelationMapper.select();
        if (list == null || list.size() < 1)
            return null;
        return list;
    }

    public List<EsbServiceConfigRelation> get(EsbServiceConfigRelation relation) {
        if (relation == null)
            return null;
        else
            return esbServiceConfigRelationMapper.selectOne(relation);
    }

    public EsbServiceConfigRelation getByServiceID(String serviceMapperID) {
        if (serviceMapperID == null)
            return null;
        else
            return esbServiceConfigRelationMapper.selectByServiceMapperID(serviceMapperID);

    }

    public EsbServiceConfigRelation getByTbNameAndSubTbName(String tbName, String subTbName) {
        if (tbName == null || subTbName == null)
            return null;
        else
            return esbServiceConfigRelationMapper.selectByTbNameAndSubTbName(tbName, subTbName);

    }

    public void insert(EsbServiceConfigRelation relation) {
        esbServiceConfigRelationMapper.insert(relation);
    }

    public void update(EsbServiceConfigRelation relation) {
        esbServiceConfigRelationMapper.update(relation);
    }

    public void delete(EsbServiceConfigRelation relation) {
        esbServiceConfigRelationMapper.delete(relation);
    }
}
